package com.mes.inventory.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Dept;
import com.mes.basicdata.domain.Part;
import com.mes.common.domain.BasicModel;
import com.mes.task.domain.Task;
 
/**
 * <p>
 * Invmanage实体，代表物料库存数量记录。
 * </p>
 * 
 */
@Entity()
@Table(name = "I_INVMANAGE")
@BatchSize(size=20)
@Lazy(value=true)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class InvInfo extends BasicModel
{

	public final static int INVTYPE_NORMAL= 0; // 存放类型，正常
	
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name="UNIQUEID")
	protected String uniqueId;

	// 物料唯一号
	@Column(name="MATERIALUSN")
	protected String materialUid;
	// 物料对象
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="MATERIALUSN",insertable=false,updatable=false)
	protected Material material;
	
	// 库房编号
	@Column(name="WAREHOUSEID")
	protected String warehouseUid;
	// 库房对象
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="WAREHOUSEID",insertable=false,updatable=false)
	protected Warehouse warehouse;

	// 柜位号
	@Column(name="BINID")
	protected String warebinUid;
	// 柜位对象
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="BINID",insertable=false,updatable=false)
	protected Warebin warebin;

	// 存放类型，0表示正常
	@Column(name="INVTYPE")
	protected Integer invType;

	// 单位
	@Column(name="UOM")
	protected String uom;
	
	// 库存数量  
	@Column(name="INVQTY")
	protected Float invQty;
	// 总金额
	@Column(name="TOTALAMOUNT")
	protected Float totalAmount;
	// 上次出入库日期
	@Column(name="INVDATE")
	protected Date lastInvDate;

	//部门编号
	@Column(name="DEPTID")
	protected String deptUid;
	// 部门对象
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEPTID",insertable=false,updatable=false)
	protected Dept dept;

	// 期初数
	@Column(name="LASTINVQTY")
	protected Float lastInvQty;
	// 期初金额
	@Column(name="LASTTOTALAMOUNT")
	protected Float lastTotalAmount;

	// 零件唯一号
	@Column(name="PART_NUMBER")
	protected String partUid;
	// 零件对象
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="PART_NUMBER",insertable=false,updatable=false)
	protected Part part;
	
	// 对应物料的图号
	@Column(name = "PART_DRAWINGID")
	protected String partDrawingId;
	// 对应物料的名称
	@Column(name = "PART_NAME")
	protected String partName;
	// 对应物料的版次
	@Column(name = "PART_VERSIONID")
	protected String partVersionId;
	// 对应物料的规格
	@Column(name = "PART_DESCRIPTION")
	protected String partDescription;
	// 对应物料的类型
	@Column(name = "PART_TYPE")
	protected String materialType;
	
	// 批次号
	@Column(name = "BATCHNUM")
	protected String batchNum;
	// 序号
	@Column(name = "SN")
	protected String sn;

	// 任务编号
	@Column(name = "TASKUID")
	protected String taskUid;
	// 任务对象
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="TASKUID",insertable=false,updatable=false)
	protected Task task;

	// 本期入库数量
	@Column(name = "THISINVQTYIN")
	protected Float thisInvQtyIn;
	// 本期入库金额
	@Column(name = "THISTOTALAMOUNTIN")
	protected Float thisTotalAmountIn;
	// 本期出库数量
	@Column(name = "THISINVQTYOUT")
	protected Float thisInvQtyOut;
	// 本期出库金额
	@Column(name = "THISTOTALAMOUNTOUT")
	protected Float thisTotalAmountOut;
	// 冻结状态，即是否冻结
	@Column(name = "FREEZED")
	protected Boolean isFreezed;
	// 末次入库日期
	@Column(name = "LATEST_IN_DATE")
	protected Date latestInDate;
	// 末次出库日期
	@Column(name = "LATEST_OUT_DATE")
	protected Date latestOutDate;
	// 冻结原因
	@Column(name = "FREEZED_REASON")
	protected String freezedReason;
	// 冻结单号
	@Column(name = "INVFREEZEDID")
	protected String invFreezedId;

	
	/** default constructor */
	public InvInfo()
	{
	}

	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	public String getMaterialUid() {
		return materialUid;
	}

	public void setMaterialUid(String materialUid) {
		this.materialUid = materialUid;
	}

	public Material getMaterial() {
		return material;
	}

	public void setMaterial(Material material) {
		this.material = material;
	}

	public String getWarehouseUid() {
		return warehouseUid;
	}

	public void setWarehouseUid(String warehouseUid) {
		this.warehouseUid = warehouseUid;
	}

	public Warehouse getWarehouse() {
		return warehouse;
	}

	public void setWarehouse(Warehouse warehouse) {
		this.warehouse = warehouse;
	}

	public String getWarebinUid() {
		return warebinUid;
	}

	public void setWarebinUid(String warebinUid) {
		this.warebinUid = warebinUid;
	}

	public Warebin getWarebin() {
		return warebin;
	}

	public void setWarebin(Warebin warebin) {
		this.warebin = warebin;
	}

	public Integer getInvType() {
		return invType;
	}

	public void setInvType(Integer invType) {
		this.invType = invType;
	}

	public String getUom() {
		return uom;
	}

	public void setUom(String uom) {
		this.uom = uom;
	}

	public Float getInvQty() {
		return invQty;
	}

	public void setInvQty(Float invQty) {
		this.invQty = invQty;
	}

	public Float getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(Float totalAmount) {
		this.totalAmount = totalAmount;
	}

	public Date getLastInvDate() {
		return lastInvDate;
	}

	public void setLastInvDate(Date lastInvDate) {
		this.lastInvDate = lastInvDate;
	}

	public String getDeptUid() {
		return deptUid;
	}

	public void setDeptUid(String deptUid) {
		this.deptUid = deptUid;
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
	}

	public Float getLastInvQty() {
		return lastInvQty;
	}

	public void setLastInvQty(Float lastInvQty) {
		this.lastInvQty = lastInvQty;
	}

	public Float getLastTotalAmount() {
		return lastTotalAmount;
	}

	public void setLastTotalAmount(Float lastTotalAmount) {
		this.lastTotalAmount = lastTotalAmount;
	}

	public String getPartUid() {
		return partUid;
	}

	public void setPartUid(String partUid) {
		this.partUid = partUid;
	}

	public Part getPart() {
		return part;
	}

	public void setPart(Part part) {
		this.part = part;
	}

	public String getPartDrawingId() {
		return partDrawingId;
	}

	public void setPartDrawingId(String partDrawingId) {
		this.partDrawingId = partDrawingId;
	}

	public String getPartName() {
		return partName;
	}

	public void setPartName(String partName) {
		this.partName = partName;
	}

	public String getPartVersionId() {
		return partVersionId;
	}

	public void setPartVersionId(String partVersionId) {
		this.partVersionId = partVersionId;
	}

	public String getPartDescription() {
		return partDescription;
	}

	public void setPartDescription(String partDescription) {
		this.partDescription = partDescription;
	}

	public String getBatchNum() {
		return batchNum;
	}

	public void setBatchNum(String batchNum) {
		this.batchNum = batchNum;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public String getTaskUid() {
		return taskUid;
	}

	public void setTaskUid(String taskUid) {
		this.taskUid = taskUid;
	}

	public Task getTask() {
		return task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	public Float getThisInvQtyIn() {
		return thisInvQtyIn;
	}

	public void setThisInvQtyIn(Float thisInvQtyIn) {
		this.thisInvQtyIn = thisInvQtyIn;
	}

	public Float getThisTotalAmountIn() {
		return thisTotalAmountIn;
	}

	public void setThisTotalAmountIn(Float thisTotalAmountIn) {
		this.thisTotalAmountIn = thisTotalAmountIn;
	}

	public Float getThisInvQtyOut() {
		return thisInvQtyOut;
	}

	public void setThisInvQtyOut(Float thisInvQtyOut) {
		this.thisInvQtyOut = thisInvQtyOut;
	}

	public Float getThisTotalAmountOut() {
		return thisTotalAmountOut;
	}

	public void setThisTotalAmountOut(Float thisTotalAmountOut) {
		this.thisTotalAmountOut = thisTotalAmountOut;
	}

	public Boolean getIsFreezed() {
		return isFreezed;
	}

	public void setIsFreezed(Boolean isFreezed) {
		this.isFreezed = isFreezed;
	}

	public Date getLatestInDate() {
		return latestInDate;
	}

	public void setLatestInDate(Date latestInDate) {
		this.latestInDate = latestInDate;
	}

	public Date getLatestOutDate() {
		return latestOutDate;
	}

	public void setLatestOutDate(Date latestOutDate) {
		this.latestOutDate = latestOutDate;
	}

	public String getFreezedReason() {
		return freezedReason;
	}

	public void setFreezedReason(String freezedReason) {
		this.freezedReason = freezedReason;
	}

	public String getInvFreezedId() {
		return invFreezedId;
	}

	public void setInvFreezedId(String invFreezedId) {
		this.invFreezedId = invFreezedId;
	}

	public String getMaterialType() {
		return materialType;
	}

	public void setMaterialType(String materialType) {
		this.materialType = materialType;
	}
	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.getUniqueId();
	}

	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.setUniqueId(uuid);
	}
	
}